<script setup lang="ts">
import { useGetAuthUrl } from '@fl/api/supplier'
// import { useUserStore } from '@fl/store/modules/user'

// const roleName = computed(() => useUserStore().getUserInfo?.sysUser?.roles[0]?.roleName || '')

// const redirectUrl = roleName.value === '供应商' ? '/supplier-pages/enterprise-management/electronic-seal' : '/purchase-pages/purchase-enterprise-management/electronic-seal'
const redirectUrl = location.href

const params = computed(() => ({
    redirectUrl,
    flag: true,
}))
const { data } = useGetAuthUrl(params)

function accredit(url) {
    if (!url)
        return
    window.open(url, '_self')
}
</script>

<template>
    <div style="min-height: 500px;">
        <ElButton v-if="!data?.isAuthorized"
                  type="primary"
                  @click="accredit(data?.authUrl)"
        >
            点击授权
        </ElButton>

        <span v-else
              class="text-16"
        >已授权</span>
    </div>
</template>

<style lang="scss" scoped></style>
